第15步:现在让我们自定义空格键事件,让小行星飞过控制台!

  • .set_x_speed() 前的名称更改为 rock

To navigate the page using the TAB key, first press ESC to exit the code editor.

stage.set_background("moon") sprite = codesters.Sprite("astronaut1") sprite.go_to(-125, -150) glorp = codesters.Sprite("alien1") glorp.go_to(100, -125) rock = codesters.Sprite("asteroid") rock.go_to(100, 75) sprite.say("What do planets read?") sprite.set_say_color("white") def click(sprite): sprite.say("Comet books!") sprite.turn_left(360) # add other actions... sprite.event_click(click) def space_bar(): sprite.jump(5) # add other actions... stage.event_key("space", space_bar)
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)